function searchPreview() {
	Ext.form.Field.prototype.msgTarget = 'side';
	Ext.QuickTips.init();
	var pm = decodeURI(window.location.href);
	var num = pm.indexOf("?");
	var n2 = pm.indexOf("&");
	var keys = pm.substring(num + 3, n2);
	var must_ptype_sc = pm.substring(n2 + 1);
	var n3 = must_ptype_sc.indexOf("&");
	var must = must_ptype_sc.substring(0, n3);
	var ptype_sc = must_ptype_sc.substring(n3 + 1);
	var n4 = ptype_sc.indexOf('&');
	var ptype = ptype_sc.substring(0, n4);
	var sc = ptype_sc.substring(n4 + 1);
	var keywordSm = new Ext.grid.RowSelectionModel({
		singleSelect : true
	});
	var keywordDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'keywords',
			id : 'id',
			fields : [ {
				name : 'id'
			}, {
				name : 'keyword'
			}, {
				name : 'num'
			} ]
		})
	});
	var keywordCm = new Ext.grid.ColumnModel([
			new Ext.grid.RowNumberer(),
			{
				header : '关键字',
				dataIndex : 'keyword',
				width : 140,
				renderer : function(v) {
					if (v.length > 5)
						return '<a href="javascript:searchKeyword(\'' + v
								+ '\')"><div qtip=' + v + '>'
								+ v.substring(0, 5) + '</div></a>';
					return '<a href="javascript:searchKeyword(\'' + v + '\')">'
							+ v + '</a>';
				}
			}, {
				header : '频率',
				dataIndex : 'num',
				width : 30
			} ]);
	var keywordGrid = new Ext.grid.GridPanel({
		ds : keywordDs,
		cm : keywordCm,
		sm : keywordSm,
		viewConfig : {
			forceFit : true
		},
		stripeRows : true,
		loadMask : true
	});
	keywordDs.baseParams = {
		cmd : 'keysubject',
		action : 'findKeyFrequent',
		keys : keys,
		start : 0,
		limit : 25
	};
	keywordDs.on('load', function(ds) {
		// ds.sort('num','DESC');
	});

	var resultSm = new Ext.grid.RowSelectionModel({
		singleSelect : true
	});
	var resultDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'results',
			totalProperty : 'totalCount',
			id : 'id',
			fields : [ {
				name : 'id'
			}, {
				name : 'name'
			}, {
				name : 'type'
			}, {
				name : 'p_type'
			}, {
				name : 'updateTime'
			}, {
				name : 'keywords'
			}, {
				name : 'tags'
			}, {
				name : 'actors'
			}, {
				name : 'directors'
			}, {
				name : 'description'
			} ]
		})
	});
	var resultCm = new Ext.grid.ColumnModel([
			new Ext.grid.RowNumberer(),
			{
				header : TXT_info_name,
				dataIndex : 'name',
				width : 165,
				renderer : function(v) {
					if (v.length > 5)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 5)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : TXT_info_type,
				dataIndex : 'type',
				width : 62,
				renderer : function(v) {
					if (v.length > 3)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 3)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : TXT_info_p_type,
				dataIndex : 'p_type',
				width : 75,
				renderer : function(v) {
					if (v.length > 2)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 2)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : '更新时间',
				dataIndex : 'updateTime',
				width : 115,
				renderer : function(v) {
					return v.substring(2, 10);
				}
			},
			{
				header : '关键字',
				dataIndex : 'keywords',
				width : 160,
				renderer : function(v) {
					if (v.length > 4)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 4)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : '标签',
				dataIndex : 'tags',
				width : 65,
				renderer : function(v) {
					if (v.length > 2)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 2)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : '演员',
				dataIndex : 'actors',
				width : 65,
				renderer : function(v) {
					if (v.length > 2)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 2)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : '导演',
				dataIndex : 'directors',
				width : 65,
				renderer : function(v) {
					if (v.length > 2)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 2)
								+ ".." + "</div>";
					return v;
				}
			}, {
				header : TXT_info_description,
				dataIndex : 'description',
				width : 20,
				renderer : function(v) {
					return "<div ext:qtip='" + v + "'>..</div>";
				}
			} ]);
	var btnReturn = new Ext.Button({
		text : TXT_common_return,
		tooltip : TXT_common_return,
		iconCls : 'icoOut'
	});
	btnReturn.on('click', function() {
		window.location.href = encodeURI('./keysubject.htm');
	});
	var resultGrid = new Ext.grid.GridPanel({
		ds : resultDs,
		title : '搜索结果: "' + keys + '" in ' + ptype + '.keywords',
		cm : resultCm,
		sm : resultSm,
		region : 'north',
		height : document.documentElement.clientHeight / 2 - 12,
		stripeRows : true,
		loadMask : {
			meg : 'loading....'
		},
		viewConfig : {
			forceFit : true
		},
		tbar : [ '-', btnReturn, '-' ],
		bbar : new Ext.PagingToolbar({
			pageSize : 8,
			height : 20,
			store : resultDs,
			displayInfo : true,
			displayMsg : TXT_common_paging,
			emptyMsg : TXT_common_no
		})
	});
	resultDs.baseParams = {
		cmd : 'keysubject',
		action : 'searchResultByKeysInPtype',
		keys : keys,
		must : must,
		ptype : ptype
	};

	var otherSm = new Ext.grid.RowSelectionModel({
		singleSelect : true
	});
	var otherDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'results',
			totalProperty : 'totalCount',
			id : 'id',
			fields : [ {
				name : 'id'
			}, {
				name : 'name'
			}, {
				name : 'type'
			}, {
				name : 'p_type'
			}, {
				name : 'updateTime'
			}, {
				name : 'keywords'
			}, {
				name : 'tags'
			}, {
				name : 'actors'
			}, {
				name : 'directors'
			}, {
				name : 'description'
			} ]
		})
	});
	var otherCm = new Ext.grid.ColumnModel([
			new Ext.grid.RowNumberer(),
			{
				header : TXT_info_name,
				dataIndex : 'name',
				width : 165,
				renderer : function(v) {
					if (v.length > 5)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 5)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : TXT_info_type,
				dataIndex : 'type',
				width : 62,
				renderer : function(v) {
					if (v.length > 3)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 3)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : TXT_info_p_type,
				dataIndex : 'p_type',
				width : 75,
				renderer : function(v) {
					if (v.length > 2)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 2)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : '更新时间',
				dataIndex : 'updateTime',
				width : 115,
				renderer : function(v) {
					return v.substring(2, 10);
				}
			},
			{
				header : '关键字',
				dataIndex : 'keywords',
				width : 160,
				renderer : function(v) {
					if (v.length > 4)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 4)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : '标签',
				dataIndex : 'tags',
				width : 65,
				renderer : function(v) {
					if (v.length > 2)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 2)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : '演员',
				dataIndex : 'actors',
				width : 65,
				renderer : function(v) {
					if (v.length > 2)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 2)
								+ ".." + "</div>";
					return v;
				}
			},
			{
				header : '导演',
				dataIndex : 'directors',
				width : 65,
				renderer : function(v) {
					if (v.length > 2)
						return "<div ext:qtip='" + v + "'>" + v.substring(0, 2)
								+ ".." + "</div>";
					return v;
				}
			}, {
				header : TXT_info_description,
				dataIndex : 'description',
				width : 20,
				renderer : function(v) {
					return "<div ext:qtip='" + v + "'>..</div>";
				}
			} ]);
	var otherGrid = new Ext.grid.GridPanel({
		title : '其他相关结果 "' + keys + '" in other ptypes.keywords except '
				+ ptype,
		ds : otherDs,
		cm : otherCm,
		sm : otherSm,
		region : 'center',
		stripeRows : true,
		loadMask : true,
		height : document.body.clientHeight / 2,
		viewConfig : {
			forceFit : true
		},
		bbar : new Ext.PagingToolbar({
			pageSize : 8,
			store : otherDs,
			height : 20,
			displayInfo : true,
			displayMsg : TXT_common_paging,
			emptyMsg : TXT_common_no
		})
	});
	otherDs.baseParams = {
		cmd : 'keysubject',
		action : 'searchResultByKeysOutPtype',
		keys : keys,
		must : must,
		ptype : ptype
	};

	var viewport = new Ext.Viewport({
		layout : 'border',
		items : [ new Ext.BoxComponent({
			region : 'north',
			el : 'north',
			height : 32,
			margins : '0 90 0 90'
		}), {
			region : 'east',
			el : 'east',
			title : '关联关键字',
			collapsible : false,
			split : true,
			width : document.body.clientWidth * 0.2,
			minSize : 175,
			maxSize : 400,
			layout : 'fit',
			margins : '0 90 0 0',
			items : [ keywordGrid ]
		}, new Ext.Panel({
			layout : 'border',
			collapsible : false,
			width : document.body.clientWidth * 0.8,
			margins : '0 0 0 90',
			region : 'center',
			el : 'center',
			items : [ resultGrid, otherGrid ]
		}), new Ext.BoxComponent({
			region : 'south',
			el : 'south',
			height : 10,
			margins : '0 90 0 90'
		}) ]
	});
	document.title = '搜索预览';
	resultDs.load({
		params : {
			start : 0,
			limit : 8,
			siteCode : sc
		}
	});
	otherDs.load({
		params : {
			start : 0,
			limit : 8,
			siteCode : sc
		}
	});
	keywordDs.load({
		params : {
			start : 0,
			limit : 90,
			siteCode : sc
		},
		callback : function() {
			if (keywordDs.reader.jsonData == '') {
				Ext.MessageBox.alert(TXT_common_hint, TXT_common_relogin,
						function() {
							window.location.href = '../eni/common/logout.jsp';
						});
				return;
			}
		}
	});
}
function searchKeyword(keyword) {
	var json = {
		"cmd" : "search",
		"keywords" : keyword,
		"fields" : "keyword",
		"order" : "time",
		"filters" : [],
		"forceManual" : "false",
		"infoToJSONObj" : "inner",
		"searchCondition" : "使用关键字 '" + keyword + "' 在关键字域进行搜索"
	};
	window.location.href = encodeURI("../htm/test.htm?q="
			+ Ext.util.JSON.encode(json));
}
Ext.onReady(searchPreview);